<?php get_instance()->view('common/header');?>

<body style="background: #ff6501;">
<img src="<?php echo $img;?>" class="wp100" alt="">

    <div class="wp90 m0a bag1 mt10" style="border-radius: 5px;">
        <div class="wp80 m0a pb10">
            <div class="logininput pr">
                <img src="<?php echo $this->staticUrl;?>img/png/pic78.png" class="heightimg" alt="">
                <input type="text" placeholder="请输入手机号" class="f09" name="mobile">
                <a href="javascript:;" class="szzz f08 dk sendyzm ">获取验证码</a>
            </div>
            <div class="logininput b0 pr">
                <img src="<?php echo $this->staticUrl;?>img/png/pic77.png" class="heightimg" alt="">
                <input type="password" placeholder="请输入手机验证码" class="f09" name="code">
            </div>
        </div>
    </div>

    <input type="hidden" name="pid" value="<?php echo isset($pid)? $pid:'0'?>">
    <button onclick="register();" class="kbtn" href="javascript:;" style="width: 60%; background: #ffe57e; color: #ff6501;margin-top: 20px;">立即领取</button>

<p class="tc cor1 f07 mt10 mb10">手机上的平价菜市 / 1小时配送到家 / 天天特价最低1分钱</p>
<img class="wp100 pb10" src="<?php echo $this->staticUrl;?>img/png/zzz3.png" alt="">
</body>

<script src="<?php echo $this->staticUrl;?>js/base.js"></script>

<script>

    $(function(){

        $('.sendyzm').click(function(){
            var phone = $('[name="mobile"]').val();
            if(phone == ""){
                show_message({status:0, message:'请输入手机号码'});
                return false;
            }
            var reg = /^0?1[3|4|5|7|8|9][0-9]\d{8}$/;
            if (!(reg.test(phone))) {
                show_message({status:0, message:'请输入正确的手机号码'});
                return false;
            }

            $.ajax({
                url: '<?php echo getUrl("user/getVerifyCode")?>',
                type:"POST",
                data:{
                    mobile:phone
                },

                success:function(arr){
                    if(arr.status == "1"){
                        tt = setInterval(time_show,1000);
                    }
                    show_message({status:arr.status, message:arr.message});

                    return false;
                },
                dataType:'json'
            });
        })

    });

    var time=60;
    function time_show(){
        if(time>1){
            time=time-1;
            $(".sendyzm").text(time+'s');
            $('[name="mobile"]').attr("readonly",true);
        }else{
            $(".sendyzm").text('重新获取');
            $('[name="mobile"]').attr("readonly",false);
            $('.sendyzm').attr('disabled',false);
            clearInterval(tt);
            time=60;
        }

    }

    function register(){
        var mobile = $('[name="mobile"]').val();
        var pid = $('[name="pid"]').val();
        var code = $('[name="code"]').val();

        var reg = /^0?1[3|4|5|7|8|9][0-9]\d{8}$/;
        if (!(reg.test(mobile))) {
            show_message({status:0, message:'请输入正确的手机号码'});
            return false;
        }

        if(code == ""){
            show_message({status:0, message:'请输入验证码'});
            return false;
        }
        $.ajax({
            url: "<?php echo getUrl('user/register')?>",
            type:"POST",
            data:{
                mobile:mobile,
                code:code,
                pid:pid,
            },
            success:function(arr){
                if(arr.status == "1"){
                    show_message({status:1, message:arr.message});
                    window.location.href=arr.url;
                }else{
                    show_message({status:0, message:arr.message});
                }
                return false;
            },
            dataType:'json'
        });
    }
</script>
</html>